<template>
    <div class="tab-control">
        <div v-for="(item , i ) in titles" :key="i" class="tab-control-item" :class="{act : index === i}"
            @click="itemClick(i)">
            <span class="item">{{item}}</span>
        </div>
    </div>
</template>



<script>

  export default {
    name: 'TabControl',
    props:{
        titles:{
            type: Array,
            default(){
                return []
            }
        }
    },
    data(){
        return {
            index : 0
        }
    },
    methods: {
        itemClick( i ){
            this.index = i
            this.$emit("tabClick" , i);
        }
    }

  }
</script>

<style>
    .tab-control{
        display: flex;
        text-align: center;
        font-size:17px;
    }
    .tab-control-item {
        flex: 1;
        height:40px;
        line-height:40px;
        width: 50px;
    }
    .act {
        color: pink;
        border-bottom: 3px solid pink;
    }
</style>